<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<jsp:include page="../common/common.jsp" />
</head>
<body class="page-header-fixed">
	<jsp:include page="../common/header.jsp" />
	<div class="clearfix"></div>
	<div class="page-container">
		<div class="page-sidebar-wrapper"><jsp:include
				page="../common/menu.jsp" /></div>
		<div class="page-content-wrapper">
			<div class="page-content">
				<div class="row">
					<div class="col-md-12">
						<form class="form-horizontal form-row-seperated" id="formid"
							action="${path}/relatedVideo/save" method="post">
							<div class="portlet box purple">
								<div class="portlet-title">
									<div class="caption">
										<i class="fa fa-shopping-cart"></i>详细信息
									</div>
									<div class="actions btn-set">
										<a href="javascript:history.go(-1);" class="btn default"><i
											class="fa fa-angle-left" title="返回">返回</i></a> <a
											href="javascript:location.reload();" class="btn green"><i
											class="fa fa-reply" title="重置">重置</i></a>
										<button type="button" class="btn blue save">
											<i class="fa fa-check" onclick="save()" title="保存">保存</i>
										</button>
									</div>
								</div>
								<div class="portlet-body">
									<div class="tabbable">
										<div class="tab-content no-space">
											<div class="tab-pane active" id="tab_general">
												<div class="form-body">
													<div class="form-group">
														<label class="col-md-2 control-label">视频名称: <span
															class="required">*</span>
														</label>
														<div class="col-md-5">
															<input type="text" id="videoName" name="videoName"
																class="form-control tags medium" value="${data.videoName}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">视频地址: <span
															class="required">*</span>
														</label>
														<div class="col-md-5">
															<input type="text" id="videoUrl" name="videoUrl"
																class="form-control tags medium" value="${data.videoUrl}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">视频时长:
														<!--  <span class="required">*</span>-->
														</label>
														<div class="col-md-5">
															<input type="text" id="videoLength" name="videoLength"
																class="form-control tags medium" value="${data.videoLength}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">发布时间: 
														<!--  <span class="required">*</span>-->
														</label>
														<div class="col-md-4">
															<div class="input-group input-large date-picker input-daterange"
																data-date-format="yyyy-mm-dd" style="width: 97px; ">
																<input type="text" class="form-control" id="releaseTime"
																name="releaseTime" value="${data.releaseTime}" readonly="readonly"
																onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 185px; " />
															</div>
														</div>
														
													</div>	
													<div class="form-group">
														<label class="col-md-2 control-label">直播名称:
														     <span class="required">*</span>
														</label>
														<div class="col-md-3">
															<select id="liveId" name="liveId" class="form-control" onchange="ckxz()">
															<option value="0" selected="selected">请选择</option>
															<c:forEach items="${datalists }" var="datalist">
																<option value="${datalist.id }" <c:if test="${data.liveId==datalist.id}">selected="selected" </c:if>>${datalist.name }</option>
															</c:forEach>							
															</select>
														</div>
														<input type="hidden" id="liveName" name="liveName"  value="" />
													</div>
												<input type="hidden" id="videoImage" name="videoImage" class="form-control" value="${data.videoImage}"/>                                         
                                                <div class="form-group">
                                                <label class="col-md-2 control-label">视频封面：</label>

                                                <div class="col-md-8">
                                                    <div class="fileinput fileinput-new" data-provides="fileinput">
                                                        <div class="fileinput-new thumbnail" style="width: 300px; height: 150px;">
                                                            <img src="${data.videoImage}">
                                                        </div>
                                                        <div class="fileinput-preview fileinput-exists thumbnail"
                                                             style="max-width: 300px; max-height: 150px;">
                                                        </div>
                                                        <div>
                                                            <span class="btn default btn-file">
                                                                <span class="fileinput-new">选择图片</span>
                                                                <span class="fileinput-exists">修改图片</span>
                                                                <input type="file" id="file" name="file"/>
                                                            </span>
                                                            <a href="#" class="btn default fileinput-exists"
                                                               data-dismiss="fileinput">移除图片
                                                            </a>
                                                        </div>
                                                    </div>
                                                </div>
                                                </div>
												</div>
											</div>
										</div>
									</div>
								</div>

								<div class="portlet-title">
									<div class="actions btn-set">
										<a href="javascript:history.go(-1);" class="btn default">
										  <i class="fa fa-angle-left" title="返回">返回</i>
										</a> 
										<a href="javascript:location.reload();" class="btn green">
										  <i class="fa fa-reply" title="重置">重置</i>
										</a>
										<button type="button" class="btn blue save">
											<i class="fa fa-check" onclick="save()" title="保存">保存</i>
										</button>
									</div>
								</div>
							</div>
							<input type="hidden" id="id" name="id" value="${data.id}">
							<input type="hidden" id="watchNumber" name="watchNumber" value="${data.watchNumber}">
							<%--  <input type="hidden" id="image" name="image" class="form-control" value="${data.image}" />--%>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
<jsp:include page="../common/footer.jsp" />
<script type="text/javascript" src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.pwstrength.bootstrap/src/pwstrength.js"></script>
<script type="text/javascript" src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/calendar/WdatePicker.js"></script>
<script type="text/javascript" src="${path}/layer/layer.js"></script>
<script>
		var editor;
		$(function() {
			editor = UE.getEditor('editor');
		});
		
		function ckxz(){
			var liveId=$("#liveId").val();
			if(liveId=='0'){
				layer.alert("请选择直播间", {
	  		        icon: 2,
	  		        offset: 'middle',
	  		        time: 3000, 
	  		        skin: 'layui-layer-lan'
	  		    });
				return false;
			}else{
				return true;
			}
		}
		
		function ckname(){
			var name=$("#videoName").val();
			if(name==null||name==""){
				layer.alert("请输入视频名称", {
	  		        icon: 2,
	  		        offset: 'middle',
	  		        time: 3000, 
	  		        skin: 'layui-layer-lan'
	  		    });
				return false;
			}else{
				return true;
			}
		}
		
		function ckurl(){
			var url=$("#videoUrl").val();
			if(url==null||url==""){
				layer.alert("视频地址不能为空", {
	  		        icon: 2,
	  		        offset: 'middle',
	  		        time: 3000, 
	  		        skin: 'layui-layer-lan'
	  		    });
				return false;
			}else{
				return true;
			}
		}
		
		/*function ckvideolength(){
			var url=$("#videoLength").val();
			if(url==null||url==""){
				layer.alert("视频时长不能为空", {
	  		        icon: 2,
	  		        offset: 'middle',
	  		        time: 3000, 
	  		        skin: 'layui-layer-lan'
	  		    });
				return false;
			}else{
				return true;
			}
		}*/
		
	  /* function ckreleaseTime(){
		 var url=$("#releaseTime").val();
		 if(url==null||url==""){
			 layer.alert("请输入该视频的发布时间", {
  		         icon: 2,
  		         offset: 'middle',
  		         time: 3000, 
  		         skin: 'layui-layer-lan'
  		     });
			 return false;
		 }else{
			 return true;
		 }
	 }*/
		function save(){
			var liveName=$("#liveId").find("option:selected").text();
			var videoImage=$("#videoImage").val();
			if(ckname()&&ckurl()&&ckxz()){
				if ($("#file").val() != null && $("#file").val() != "") {
					$.ajaxFileUpload({
						url : '${path}/conf/upload',
						async : false,
						secureuri : false,
						fileElementId : 'file',
						dataType : 'json',
						success : function(data, status) {
							if (data.statusCode == 200) {
								$("#videoImage").val(data.uri);
								$("#liveName").val(liveName);
								$("#formid").submit();
								return;
							}else{
								layer.alert("糟糕！ 图片上传失败...", {
					  		        icon: 2,
					  		        offset: 'middle',
					  		        time: 3000, 
					  		        skin: 'layui-layer-lan'
					  		    });
							}
						}
					});
				}else if(videoImage==null||videoImage==""){
					layer.alert("请选择一张图片进行上传", {
		  		        icon: 2,
		  		        offset: 'middle',
		  		        time: 3000, 
		  		        skin: 'layui-layer-lan'
		  		    });
					
				}else{
					$("#liveName").val(liveName);
					$("#formid").submit();
				}	
			}
		}
		//检测图片是否符合规范
		function checkTypes(id) {
			var File_box = document.getElementById(id);
			var extend = File_box.value.substring(File_box.value
					.lastIndexOf(".") + 1);
			if (extend == "jpg" || extend == "png" || extend == "jpeg"
					|| extend == "bmp" || extend == "gif") {
				return true;
			}
		}
</script>
</body>
</html>